<template>
	<view>
		<web-view v-if="pageType=='web'&&webLink!=''" :src="webLink"></web-view>
		<view class="articleBox">
			<view class="tit">{{details.name}}</view>
			<view v-html="pagecontent"></view>
			<view class="between timeBox">
				<view>发布时间:{{details.createtime}}</view>
				<view>
					<uni-icons type="eye"></uni-icons>{{details.readcount}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getArticleDetails
	} from "../../api/index.js"
	export default {
		data() {
			return {
				pageType: '',
				webLink: '',
				details: {},
				pagecontent: ''
			}
		},
		onLoad(opt) {
			this.pageType = opt.type
			if (this.pageType == 'web') {
				this.webLink = opt.url
			} else {
				this.id = opt.articleid
				this.getArticleDetails()
			}
			// console.log(opt, this.webLink, "****")
		},
		methods: {
			async getArticleDetails() {
				const res = await getArticleDetails('s=/ApiArticle/detail', {
					id: this.id
				})
				console.log(res)
				const {
					detail,
					pagecontent,
					msg,
					status
				} = res.data
				if (status == 1) {
					this.details = detail
					this.pagecontent = pagecontent[0].content
				} else {
					this.showToast(msg)
				}


			},

		}
	}
</script>

<style lang="scss" scoped>
	.articleBox {
		padding: 30rpx;

		.timeBox {
			margin-top: 100rpx;
			color: #999;
			font-size: 28rpx;
		}
	}

	.tit {
		text-align: center;
		font-weight: bold;
		font-size: 34rpx;
	}
</style>
